/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.general.update;
import org.mybeans.Sesion;
import java.io.File;
import javax.swing.JOptionPane;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
 *
 * @author avbravo
 */
public class XMLLookReader {
    Sesion sesion;
private String look;

    public String getLook() {
        return look;
    }

    public void setLook(String look) {
        this.look = look;
    }

    public XMLLookReader() {
        sesion = new Sesion();
    }


 public void Leer() {
        try {

            File file = new File("look.xml");
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(file);
            doc.getDocumentElement().normalize();
            NodeList nodeLst = doc.getElementsByTagName("tema");
          

            for (int s = 0; s < nodeLst.getLength(); s++) {

                Node fstNode = nodeLst.item(s);

                if (fstNode.getNodeType() == Node.ELEMENT_NODE) {

                    Element fstElmnt = (Element) fstNode;

                    NodeList nodeUsername = fstElmnt.getElementsByTagName("look");
                    Element elementoUsername = (Element) nodeUsername.item(0);
                    NodeList listaUsername = elementoUsername.getChildNodes();
                    //System.out.println("clase : " + ((Node) listaUsername.item(0)).getNodeValue());
                    look = ((Node) listaUsername.item(0)).getNodeValue();

                }

            }


           
        } catch (Exception ex) {
            if (ex.getMessage() == null) {
                JOptionPane.showMessageDialog(null, "Clase:XMLLookReader.java\nMetodo:\nLeer()\nSugerencia elimine los archivos .xml\nEnvie un email al desarrollador \navbravo@gmail.com", "Error", JOptionPane.ERROR_MESSAGE);

            } else {
                JOptionPane.showMessageDialog(null, "Clase:XMLLookReader.java\nMetodo:Leer())\nError: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            }
               look ="Metal";
        }
            

        
    }
}
